
//var ssopts.swaksmack_optionsDataBoolean        = new Array();
//var ssopts.swaksmack_optionsDataInteger        = new Array();
//var ssopts.swaksmack_optionsDataString         = new Array();

var ssopts = {
	hlchoice: "1",
	themechoice: "1",
	swaksmack_optionsDataBoolean: new Array(),
	swaksmack_optionsDataInteger: new Array(),
	swaksmack_optionsDataString: new Array(),
	themeArray: null,
	
//	var this.ssopts.swaksmack_optionsDataInteger        = new Array();
//	var this.ssopts.swaksmack_optionsDataString         = new Array();
	init: function() {
		//var tc = SS_getPreference(SMACK_TCHL1);
		//var bc = SS_getPreference(SMACK_BTCHL1);
		///org ssopts.updateSample(tc,bc);
		//alert('init page pref set ' + ssopts.isPrefSet("extensions.swaksmack.options.page_intpref"));
		if (ssopts.isPrefSet("extensions.swaksmack.options.page_intpref")) {
			var index = ssopts.getIntPref("extensions.swaksmack.options.page_intpref");
			//alert("page index " +index);
			var pageList   = document.getElementById("swaksmack-options-list");
			pageList.selectedIndex = index;
			pageList.setAttribute("src", pageList.selectedItem.value);
		}
		/*
		var cpicker = document.getElementById('tcolorpic1');
		var cpicker2 = document.getElementById('bkcolorpic1');
		
		
		var usercolor = SS_getPreference(SMACK_TCHL1);
		cpicker.color = usercolor;
		usercolor = SS_getPreference(SMACK_BTCHL1);
		cpicker2.color = usercolor;
		*/
		
	},
	getPrefService: function() {
		return Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
	},
	isPrefSet: function(preference) {
    // If the preference is set
    if(preference)
    {
    	  var preServ = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
        return preServ.prefHasUserValue(preference);
    }

    return false;
	},
getBoolPref: function(preference, userPreference) {
    // If the preference is set
    if(preference)
    {
    	//alert('ispref set ' + ssopts.isPrefSet(preference));
    	val =  Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("").getBoolPref(preference);
      //alert('bool val ' +val);
      return val;

    }
    

    return false;
},
// Gets an integer preference, returning 0 if the preference is not set
getIntPref: function (preference, userPreference) {
    // If the preference is set
    if(preference)
    {
    	return Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("").getIntPref(preference);

    }

    return 0;
},
getStringPref: function(preference, userPreference) {
    // If the preference is set
    if(preference)
    {
    	return Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("").getComplexValue(preference, Components.interfaces.nsISupportsString).data.trim();

    }

    return null;
},
setBoolPref: function(preference, value) {
 if(preference) {
   ssopts.getPrefService().setBoolPref(preference, value);
 }
},
setIntPref: function(preference, value) {
	if(preference) {
		try {
			ssopts.getPrefService().setIntPref(preference, value);
		}
		catch(exc) {alert('Error setting preference ' + preference + '. Error: ' + exc)}
	}
},
setCharPref: function(preference, value) {
	if(preference) {
		try {
			ssopts.getPrefService().setCharPref(preference, value);
		}
		catch(exc) {alert(value + ': Error setting preference ' + preference + '. Error: ' + exc)}
	}
},
clearUserPref: function(preference) {
	if (preference) {
		ssopts.getPrefService().clearUserPref(preference);
	}
},
displayBoolCheckedPref: function(preference,elementid) {
	if (preference && elementid) {
		//alert('displayBoolPref');
		var pageDocument = document.getElementById("swaksmack-options-optframe").contentDocument;
		
		if(typeof ssopts.swaksmack_optionsDataBoolean[preference] == "undefined" || ssopts.swaksmack_optionsDataBoolean[preference] == null) {
			pageDocument.getElementById(elementid).checked = ssopts.getBoolPref(preference, true);
		}
		else {
			pageDocument.getElementById(elementid).checked = ssopts.swaksmack_optionsDataBoolean[preference];
		}
		/*
    if(typeof ssopts.swaksmack_optionsDataBoolean[preference] != "undefined") {
        pageDocument.getElementById(elementid).checked = ssopts.swaksmack_optionsDataBoolean[preference];
    }
    else {
    	//alert('else true');
       // pageDocument.getElementById("checkboolpref_easyurl").checked = true;
        pageDocument.getElementById(elementid).checked = ssopts.getBoolPref(preference, true);
    }
    */
	}
	else {
		alert('else displayBoolPref');
	}
},
displayIntValuePref: function(preference,elementid) {
	if (preference && elementid) {
		//alert('displayBoolPref');
		var pageDocument = document.getElementById("swaksmack-options-optframe").contentDocument;
		
		if(typeof ssopts.swaksmack_optionsDataInteger[preference] == "undefined" || ssopts.swaksmack_optionsDataInteger[preference] == null) {
			pageDocument.getElementById(elementid).value = ssopts.getIntPref(preference, true);
		}
		else {
			pageDocument.getElementById(elementid).value = ssopts.swaksmack_optionsDataInteger[preference];
		}
		/*
    if(typeof ssopts.swaksmack_optionsDataInteger[preference] != "undefined") {
        pageDocument.getElementById(elementid).value = ssopts.swaksmack_optionsDataInteger[preference];
    }
    else {
    	//alert('else true');
       // pageDocument.getElementById("checkboolpref_easyurl").checked = true;
        pageDocument.getElementById(elementid).value = ssopts.getIntPref(preference, true);
    }
    */
	}
	else {
		alert('else displayBoolPref');
	}
},
displayStringValuePref: function(preference,elementid) {
	if (preference && elementid) {
		//alert('displayBoolPref');
		var pageDocument = document.getElementById("swaksmack-options-optframe").contentDocument;
		
		if(typeof ssopts.swaksmack_optionsDataString[preference] == "undefined" || ssopts.swaksmack_optionsDataString[preference] == null) {
			pageDocument.getElementById(elementid).value = ssopts.getStringPref(preference, true);
		}
		else {
			pageDocument.getElementById(elementid).value = ssopts.swaksmack_optionsDataString[preference];
		}
		/* org
    if(typeof ssopts.swaksmack_optionsDataString[preference] != "undefined") {
        pageDocument.getElementById(elementid).value = ssopts.swaksmack_optionsDataString[preference];
    }
    else {
    	//alert('else true');
       // pageDocument.getElementById("checkboolpref_easyurl").checked = true;
        pageDocument.getElementById(elementid).value = ssopts.getStringPref(preference, true);
    }
    */
	}
	else {
		alert('else displayStringPref');
	}
},
displayStringColorPref: function(preference,elementid) {
	if (preference && elementid) {
		//alert('displayBoolPref');
		var pageDocument = document.getElementById("swaksmack-options-optframe").contentDocument;
		
		if(typeof ssopts.swaksmack_optionsDataString[preference] == "undefined" || ssopts.swaksmack_optionsDataString[preference] == null) {
		 pageDocument.getElementById(elementid).color = ssopts.getStringPref(preference, true);
		}
		else {
			pageDocument.getElementById(elementid).color = ssopts.swaksmack_optionsDataString[preference];
		}
		
		/*
    if(typeof ssopts.swaksmack_optionsDataString[preference] != "undefined") {
        pageDocument.getElementById(elementid).color = ssopts.swaksmack_optionsDataString[preference];
    }
    else {
    	//alert('else true');
       // pageDocument.getElementById("checkboolpref_easyurl").checked = true;
        pageDocument.getElementById(elementid).color = ssopts.getStringPref(preference, true);
    }
    */
	}
	else {
		alert('else displayStringPref');
	}
},
displayStringStyleBackColorPref: function(preference,elementid) {
	if (preference && elementid) {
		//alert('displayBoolPref');
		var pageDocument = document.getElementById("swaksmack-options-optframe").contentDocument;
		
		if(typeof ssopts.swaksmack_optionsDataString[preference] == "undefined" || ssopts.swaksmack_optionsDataString[preference] == null) {
			pageDocument.getElementById(elementid).style.background = ssopts.getStringPref(preference, true);
		}
		else {
			pageDocument.getElementById(elementid).style.background = ssopts.swaksmack_optionsDataString[preference];
		}
		
		/*
    if(typeof ssopts.swaksmack_optionsDataString[preference] != "undefined") {
        pageDocument.getElementById(elementid).style.background = ssopts.swaksmack_optionsDataString[preference];
    }
    else {
    	//alert('else true');
       // pageDocument.getElementById("checkboolpref_easyurl").checked = true;
        pageDocument.getElementById(elementid).style.background = ssopts.getStringPref(preference, true);
    }
    */
	}
	else {
		alert('else displayStringPref');
	}
},
displayStringStyleColorPref: function(preference,elementid) {
	if (preference && elementid) {
		//alert('displayBoolPref');
		var pageDocument = document.getElementById("swaksmack-options-optframe").contentDocument;
		
		if(typeof ssopts.swaksmack_optionsDataString[preference] == "undefined" || ssopts.swaksmack_optionsDataString[preference] == null) {
			pageDocument.getElementById(elementid).style.color = ssopts.getStringPref(preference, true);
		}
		else {
			pageDocument.getElementById(elementid).style.color = ssopts.swaksmack_optionsDataString[preference];
		}
		
		/*
    if(typeof ssopts.swaksmack_optionsDataString[preference] != "undefined") {
        pageDocument.getElementById(elementid).style.color = ssopts.swaksmack_optionsDataString[preference];
    }
    else {
    	//alert('else true');
       // pageDocument.getElementById("checkboolpref_easyurl").checked = true;
        pageDocument.getElementById(elementid).style.color = ssopts.getStringPref(preference, true);
    }
    */
	}
	else {
		alert('else displayStringPref');
	}
},
	initAllOptions: function() {
		ssopts.initializeUrl();
		ssopts.initializeTinyUrl();
		ssopts.initializeAudio();
		ssopts.initializeHighlight();
		ssopts.initializeChatTheme();
		ssopts.initializeAlerts();
		ssopts.initializeIgnore();
		ssopts.initializeAdvanced();
	},
	initializeUrl: function() {
	//	alert('initUrl');
	//	var pageDocument = document.getElementById("swaksmack-options-optframe").contentDocument;

    //alert(ssopts.getBoolPref("extensions.swaksmack.easyurl_boolpref1", true));

	ssopts.displayBoolCheckedPref("extensions.swaksmack.easyurl_boolpref1", "checkboolpref_easyurl");
	ssopts.displayBoolCheckedPref("extensions.swaksmack.maxurl_boolpref1", "checkboolpref_maxurl");
	ssopts.displayIntValuePref("extensions.swaksmack.maxurllength_intpref","textintpref_maxurllength");
	ssopts.displayStringValuePref("extensions.swaksmack.truncurl_stringpref","textstringpref_truncurl");
	
	ssopts.initializeTinyUrl();
 // ssopts.displayBoolCheckedPref("extensions.swaksmack.tinyurl_enable_boolpref1", "checkboolpref_tinyurl_enable");
//	ssopts.displayIntValuePref("extensions.swaksmack.tinyurl_maxurllength_intpref","textintpref_tinyurl_maxurllength");
   
	},
	initializeTinyUrl: function() {
//		alert('initTinyUrl');
		//alert('initUrl');

  ssopts.displayBoolCheckedPref("extensions.swaksmack.tinyurl_enable_boolpref1", "checkboolpref_tinyurl_enable");
	ssopts.displayIntValuePref("extensions.swaksmack.tinyurl_maxurllength_intpref","textintpref_tinyurl_maxurllength");
	ssopts.displayBoolCheckedPref("extensions.swaksmack.tinyurl_enablepreview_boolpref", "checkboolpref_tinyurl_enablepreview");
   
	},
	initializeAudio: function() {
		ssopts.displayBoolCheckedPref("extensions.swaksmack.audio.global_enable_boolpref", "audio_global_enable");
		ssopts.displayStringValuePref("extensions.swaksmack.audio.outwitsound_stringpref","audioFile");
	},
	initializeHighlight: function() {
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.enablehl_boolpref1", "checkboolpref_enablehl");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.ignorecasehl_boolpref1", "checkboolpref_ignorecasehl");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.ignoreselfposts_boolpref1", "checkboolpref_ignoreselfposts");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.enableinlrhl_boolpref1", "checkboolpref_enableinlrhl");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.enableJFEmployee_boolpref1","checkboolpref_enablejfemployeehl");		
		
		
		ssopts.displayStringValuePref("extensions.swaksmack.hl.dynamicusername_stringpref","dynamic-usernamic");
		ssopts.displayStringValuePref("extensions.swaksmack.hl.dynamickeyword_stringpref","dynamic-keyword");
		ssopts.displayStringValuePref("extensions.swaksmack.hl.jellyfishemployee_stringpref","dynamic-jfemployee");
		
		ssopts.initializeHighlight1();
		//ssopts.initializeChatTheme();
		
		
		
		
		
		
	},
	initializeHighlight1: function() {
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.enablehl1_boolpref1","checkboolpref_hloptionenable1");		
		ssopts.displayStringValuePref("extensions.swaksmack.hl.keywordshl1_stringpref","textstringpref_keywordshl1");
		ssopts.displayStringValuePref("extensions.swaksmack.hl.usernamehl1_stringpref","textstringpref_usernamehl1");
		ssopts.displayStringColorPref("extensions.swaksmack.hl.hltextcolor1_stringpref","tcolorpic1");
		ssopts.displayStringColorPref("extensions.swaksmack.hl.hlbkcolor1_stringpref","bkcolorpic1");
		ssopts.displayStringValuePref("extensions.swaksmack.hl.hltextcolor1_stringpref","textstringpref_hltextcolor1");
		ssopts.displayStringValuePref("extensions.swaksmack.hl.hlbkcolor1_stringpref","textstringpref_hlbkcolor1");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.hlunderline1_boolpref1", "checkboolpref_hlunderline1");
		//ssopts.displayBoolCheckedPref("extensions.swaksmack.hlitalic1_boolpref1", "checkboolpref_ignorecasehl");
		//ssopts.displayBoolCheckedPref("extensions.swaksmack.hlbold1_boolpref1", "checkboolpref_ignoreselfposts");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.usernameonlyhl1_boolpref1", "checkboolpref_usernameonlyhl");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.wordonlyhl1_boolpref1", "checkboolpref_wordonlyhl");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.postoutlinehl1_boolpref1", "checkboolpref_postoutlinehl");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.chatwildcard1_boolpref1", "checkboolpref_chatwildcard");
		ssopts.displayStringStyleColorPref("extensions.swaksmack.hl.hltextcolor1_stringpref","hlSampleText");
		ssopts.displayStringStyleBackColorPref("extensions.swaksmack.hl.hlbkcolor1_stringpref","hlSampleText");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.chatinfohl1_boolpref1", "checkboolpref_chatinfohl"); 	
		ssopts.hlchoice = "1";
	},	
	initializeHighlight2: function() {
		//hl2
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.enablehl2_boolpref1","checkboolpref_hloptionenable1");		
		ssopts.displayStringValuePref("extensions.swaksmack.hl.keywordshl2_stringpref","textstringpref_keywordshl1");
		ssopts.displayStringValuePref("extensions.swaksmack.hl.usernamehl2_stringpref","textstringpref_usernamehl1");
		ssopts.displayStringColorPref("extensions.swaksmack.hl.hltextcolor2_stringpref","tcolorpic1");
		ssopts.displayStringColorPref("extensions.swaksmack.hl.hlbkcolor2_stringpref","bkcolorpic1");
		ssopts.displayStringValuePref("extensions.swaksmack.hl.hltextcolor2_stringpref","textstringpref_hltextcolor1");
		ssopts.displayStringValuePref("extensions.swaksmack.hl.hlbkcolor2_stringpref","textstringpref_hlbkcolor1");		
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.hlunderline2_boolpref1", "checkboolpref_hlunderline1");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.usernameonlyhl2_boolpref1", "checkboolpref_usernameonlyhl");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.wordonlyhl2_boolpref1", "checkboolpref_wordonlyhl");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.postoutlinehl2_boolpref1", "checkboolpref_postoutlinehl");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.chatwildcard2_boolpref1", "checkboolpref_chatwildcard");
		ssopts.displayStringStyleColorPref("extensions.swaksmack.hl.hltextcolor2_stringpref","hlSampleText");
		ssopts.displayStringStyleBackColorPref("extensions.swaksmack.hl.hlbkcolor2_stringpref","hlSampleText");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.chatinfohl2_boolpref1", "checkboolpref_chatinfohl");  
	
	},	
	initializeHighlight3: function() {
		//hl3
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.enablehl3_boolpref1","checkboolpref_hloptionenable1");
		ssopts.displayStringValuePref("extensions.swaksmack.hl.keywordshl3_stringpref","textstringpref_keywordshl1");
		ssopts.displayStringValuePref("extensions.swaksmack.hl.usernamehl3_stringpref","textstringpref_usernamehl1");
		ssopts.displayStringColorPref("extensions.swaksmack.hl.hltextcolor3_stringpref","tcolorpic1");
		ssopts.displayStringColorPref("extensions.swaksmack.hl.hlbkcolor3_stringpref","bkcolorpic1");
		ssopts.displayStringValuePref("extensions.swaksmack.hl.hltextcolor3_stringpref","textstringpref_hltextcolor1");
		ssopts.displayStringValuePref("extensions.swaksmack.hl.hlbkcolor3_stringpref","textstringpref_hlbkcolor1");		
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.hlunderline3_boolpref1", "checkboolpref_hlunderline1");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.usernameonlyhl3_boolpref1", "checkboolpref_usernameonlyhl");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.wordonlyhl3_boolpref1", "checkboolpref_wordonlyhl");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.postoutlinehl3_boolpref1", "checkboolpref_postoutlinehl");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.chatwildcard3_boolpref1", "checkboolpref_chatwildcard");
		ssopts.displayStringStyleColorPref("extensions.swaksmack.hl.hltextcolor3_stringpref","hlSampleText");
		ssopts.displayStringStyleBackColorPref("extensions.swaksmack.hl.hlbkcolor3_stringpref","hlSampleText");
	  ssopts.displayBoolCheckedPref("extensions.swaksmack.hl.chatinfohl3_boolpref1", "checkboolpref_chatinfohl"); 
	
	},
	initializeChatTheme: function() {
		ssopts.displayBoolCheckedPref("extensions.swaksmack.theme.enabletheme_boolpref1","checkboolpref_themeenable");
		ssopts.displayStringColorPref("extensions.swaksmack.theme.bkcolor1_stringpref","theme-colorpic1");
		ssopts.displayStringValuePref("extensions.swaksmack.theme.bkcolor1_stringpref","textstringpref_chatthemecolor1");
		ssopts.themechoice = "1";
		//alert('initializeChatTheme pre choices');
		ssopts.initThemeChoices();
		ssopts.initThemeColors();
		ssopts.updateThemeSample();
		
		
	},		
	initializeAlerts: function() {
		ssopts.displayBoolCheckedPref("extensions.swaksmack.alerts.global_enable_boolpref", "checkboolpref_enableglobalalerts"); 
		ssopts.displayStringValuePref("extensions.swaksmack.outwitwarn_pref1","outwitWarnMenu");
		ssopts.displayStringValuePref("extensions.swaksmack.outwitvotewarn_pref1","voteWarnMenu");
		ssopts.displayStringValuePref("extensions.swaksmack.guruguesswarn_pref1","guruWarnMenu"); 
		ssopts.displayStringValuePref("extensions.swaksmack.smackpotwarn_pref1","smackpotWarnMenu");
    ssopts.displayBoolCheckedPref("extensions.swaksmack.outwitrandom_pref1", "checkboolpref_outwitrandom"); 
    ssopts.displayBoolCheckedPref("extensions.swaksmack.altalertmonitor_boolpref1", "checkboolpref_altalertmonitor");   
    ssopts.displayBoolCheckedPref("extensions.swaksmack.enablealertmonitor_boolpref1", "checkboolpref_enablealertmonitordelay");  
    //ssopts.displayBoolCheckedPref("extensions.swaksmack.pmchatcheck_boolpref1", "checkboolpref_pmlrmonitorenable");
	},
	initializeIgnore: function() {
		ssopts.displayBoolCheckedPref("extensions.swaksmack.ignore.enableignoreposts_boolpref1", "checkboolpref_enableignoreposts");
		ssopts.displayStringValuePref("extensions.swaksmack.ignore.ignorelist1_stringpref","textstringpref_ignorelist1");
		ssopts.displayStringValuePref("extensions.swaksmack.ignore.ignorelist2_stringpref","textstringpref_ignorelist2");		
		ssopts.displayStringValuePref("extensions.swaksmack.ignore.ignorelistattend1_stringpref","textstringpref_ignorelistattend1");
    ssopts.displayBoolCheckedPref("extensions.swaksmack.blockwildcard_boolpref1", "checkboolpref_blockwildcard");
	  var funignore = ssopts.getBoolPref("extensions.swaksmack.ignore.funignore_boolpref1");
	  var pageDocument = document.getElementById("swaksmack-options-optframe").contentDocument;
	  if (funignore == true) {
	  	pageDocument.getElementById("radiopref_ignoremode").selectedIndex = 1;
	  }
	  else {
	  	pageDocument.getElementById("radiopref_ignoremode").selectedIndex = 0;
	  }
	  ssopts.displayBoolCheckedPref("extensions.swaksmack.ignore.enableCapsSupression_boolpref1", "checkboolpref_capsupression");
	  ssopts.displayIntValuePref("extensions.swaksmack.ignore.enableCapsThreshold_intpref1","textintpref_capsuppressionthreshold");
	  
	  
	  
	  
	},
	initializeEnhance: function() {
		ssopts.displayBoolCheckedPref("extensions.swaksmack.enhancedChatUI_boolpref","checkboolpref_enhanceenabled");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.enhancedChatUIIcons_boolpref","checkboolpref_enhanceicons");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.enhancedHideAvatars_boolpref","checkboolpref_enhancehideavatars");
		ssopts.displayStringValuePref("extensions.swaksmack.replyprefix_stringpref","textstringpref_replyprefix");
		ssopts.displayStringValuePref("extensions.swaksmack.replysuffix_stringpref","textstringpref_replysuffix");
		
		
	},
	initializeAppearance: function() {
		ssopts.displayBoolCheckedPref("extensions.swaksmack.appearance.displaystatusbarkw_boolpref1", "appearance_sb_kw_enable");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.appearance.displaystatusbarpm_boolpref1", "appearance_sb_pm_enable");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.appearance.displaystatusbarlr_boolpref1", "appearance_sb_lr_enable");
		ssopts.displayBoolCheckedPref("extensions.swaksmack.appearance.displaystatusbarsale_boolpref1", "appearance_sb_sale_enable");
	},
	initializeAdvanced: function() {
		ssopts.displayIntValuePref("extensions.swaksmack.adv.chatspeed_intpref","intpref_adv_chatspeed");
	},			
	selectPage: function(pageList) {
		//alert('select page ' + pageList.selectedItem.value);
		ssopts.cacheOptions();
		
		ssopts.setIntPref("extensions.swaksmack.options.page_intpref", pageList.selectedIndex);
		//alert("set last page " + pageList.selectedIndex);
		document.getElementById("swaksmack-options-optframe").setAttribute("src", pageList.selectedItem.value);
	},
	initThemeChoices: function() {
		//alert('initThemeChoices entry');
		var sct = ssopts.getStringPref("extensions.swaksmack.theme.userThemes_stringpref",true);
		//alert('sct ' + sct);
		ssopts.themeArray = buildSwakChatThemes(sct);
		//alert(ct[1].name + ' ' + ct[0].name);
		if(ssopts.themeArray == null) return;
		var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;
		var menulist = pageDocument.getElementById('theme-choices');
		menulist.removeAllItems();
		for (var i=0;i<ssopts.themeArray.length;i++) {
			//alert('adding to them menulist');
			menulist.appendItem(ssopts.themeArray[i].name,ssopts.themeArray[i].name);
		}
		var ctheme = ssopts.getStringPref("extensions.swaksmack.theme.currentTheme_stringpref");
		if (ctheme != null) {
			//alert('initThemeChoices currenttheme ' + ctheme);
			if (ctheme == "Custom") {
				menulist.insertItemAt(0,"Custom","Custom");
			}
			ssopts.themechoice = ctheme;
			menulist.value = ctheme;
		}
	},
	updateTextColor: function() {
		var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;
		var cpicker = pageDocument.getElementById('tcolorpic1');
		var textColor = pageDocument.getElementById('textstringpref_hltextcolor1');
		textColor.value = cpicker.color;
		ssopts.updateSample(textColor.value, null);
	},
	updateBackgroundColor: function() {
		var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;		
		var cpicker = pageDocument.getElementById('bkcolorpic1');
		var textColor = pageDocument.getElementById('textstringpref_hlbkcolor1');
		textColor.value = cpicker.color;
		ssopts.updateSample(null, textColor.value);
	},
	textboxColorChange: function(event) {
		var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;		
		var textColor = event.target;
		var newcolor;
		if (textColor.id == 'textstringpref_hlbkcolor1') {
		var cpicker = pageDocument.getElementById('bkcolorpic1');
		cpicker.color = textColor.value;
		ssopts.updateSample(null, textColor.value);
		}
		else if(textColor.id == 'textstringpref_hltextcolor1') {
			var cpicker = pageDocument.getElementById('tcolorpic1');
			cpicker.color = textColor.value;
			ssopts.updateSample(textColor.value,null);
		}
		
	},
	updateThemeColor: function() {
		var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;
		var cpicker = pageDocument.getElementById('theme-colorpic1');
		var textColor = pageDocument.getElementById('textstringpref_chatthemecolor1');
		textColor.value = cpicker.color;
		ssopts.cacheThemeOptions(ssopts.themechoice);
		ssopts.updateThemeSample();	
		ssopts.createCustomThemeItem();
	//	ssopts.updateThemeSample();
		//ssopts.updateSample(textColor.value, null);
	},	
	textboxThemeColorChange: function(event) {
		var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;		
		var textColor = event.target;
		var newcolor;
		if (textColor.id == 'textstringpref_chatthemecolor1') {
		var cpicker = pageDocument.getElementById('theme-colorpic1');
		cpicker.color = textColor.value;
	//	ssopts.updateSample(null, textColor.value);
		}
		else if(textColor.id == 'textstringpref_chatthemecolor1') {
			var cpicker = pageDocument.getElementById('theme-colorpic1');
			cpicker.color = textColor.value;
			//ssopts.updateSample(textColor.value,null);
		}
		ssopts.cacheThemeOptions(ssopts.themechoice);
		ssopts.updateThemeSample();	
		//change menulist from default??? --TODO
		//var menulist = pageDocument.getElementById('theme-choices');
		
	},		
	themeColorChange: function(textColor,backgroundColor) {
	  var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;
		pageDocument.getElementById('textstringpref_hltextcolor1').value = textColor;
		pageDocument.getElementById('textstringpref_hlbkcolor1').value = backgroundColor;
		//var hlc = pageDocument.getElementById('highlightChoice');
		/*
		//alert('hlc value ' +hlc.value);
		if (hlc.value == "1") {
			SS_prefs.setCharPref(SMACK_TCHL1,textColor);
			SS_prefs.setCharPref(SMACK_BTCHL1,backgroundColor);
		}
		if (hlc.value == "2") {
			SS_prefs.setCharPref(SMACK_TCHL2,textColor);
			SS_prefs.setCharPref(SMACK_BTCHL2,backgroundColor);
		}
		if (hlc.value == "3") {
			SS_prefs.setCharPref(SMACK_TCHL3,textColor);
			SS_prefs.setCharPref(SMACK_BTCHL3,backgroundColor);
		}		
		*/
		var cpicker = pageDocument.getElementById('bkcolorpic1');
		cpicker.color = backgroundColor;
		cpicker = pageDocument.getElementById('tcolorpic1');
		cpicker.color = textColor;
		
		//ssopts.updateSample(null, textColor.value);
		ssopts.updateSample(textColor,backgroundColor);
		
	},
	updateThemeSample: function() {
		var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;
		var themeframe = pageDocument.getElementById('swaksmack-options-themeframe');
		//alert('themeframe ' + themeframe);
		var tdoc = themeframe.contentDocument;
		var cp = tdoc.getElementById('chatPost');
		//alert('theme cp ' + cp);
		var ct = tdoc.getElementById('commentText');
		//alert('post text ' + ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATTC]);
		ct.style.color = ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATTC];
		//ct.style.background = ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATBTC];
		//alert('post bkgrd ' + ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATBTC]);
		cp.style.background = ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATBTC];
		var ca = tdoc.getElementById('chatMute');
		ca.style.color = ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATACTIONS];
		ca = tdoc.getElementById('chatHighlight');
		ca.style.color = ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATACTIONS];
		ca = tdoc.getElementById('chatReply');
		ca.style.color = ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATACTIONS];
		var cn = tdoc.getElementById('chatNick');
		cn.style.color = ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATNICK];
		var cg = tdoc.getElementById('chatGuru');
		cg.style.color = ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATGURU];
		var ctime = tdoc.getElementById('chatTime');
		ctime.style.color = ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATTIME];
		var cbg = tdoc.getElementById('chatBG');
		cbg.style.background = ssopts.swaksmack_optionsDataString[SMACK_THEME_BKGRD];
		
	},
	updateSample: function(tc, bc) {
		var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;
		var l = pageDocument.getElementById('hlSampleText');
		if (tc != null) l.style.color=tc;
		if (bc != null) l.style.background=bc;
	},
	selectAudio: function() {
		var am = swaksmack.audioManager;
		if (am == null) am = new AudioManager();
		var fc = new FileChooser('Select Audio File',am);
		fc.open();
		ssopts.initializeAudio();
	},
	playAudio: function() {
		var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;
		var af = pageDocument.getElementById('audioFile').value;
		var am = swaksmack.audioManager;
		if (am == null) am = new AudioManager();
		am.playAudioAlert(af);
	},
	resetAudio: function(parent) {
		//var af = document.getElementById('audioFile').value;
		//alert('resetAudio af ' + af);
		var answer = confirm('Reset audio to default value?');
		if (answer) {
			//var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch).getBranch("");
			var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
	 		if (prefs == null) return;
			var optionitems = new Array();
	 		optionitems = optionitems.concat(SMACK_AUDIO_OPTIONITEMS);
	 		for (var i=optionitems.length-1;i>=0;i--){
			 	try {
			 		prefs.clearUserPref(optionitems[i]);
			 	} catch (Exception){}
			}
			ssopts.initializeAudio();
		}
	},
	enableGlobalAudio: function(comp) {
		
		//alert(comp.checked);
		if (comp.getAttribute("checked") == "true") {
			ssopts.setBoolPref("extensions.swaksmack.audio.global_enable_boolpref",true);
		}
		else {
			ssopts.setBoolPref("extensions.swaksmack.audio.global_enable_boolpref",false);
		}

	},
	enableGlobalAlerts: function(comp) {
		
		//alert(comp.checked);
		if (comp.getAttribute("checked") == "true") {
			ssopts.setBoolPref("extensions.swaksmack.alerts.global_enable_boolpref",true);
		}
		else {
			ssopts.setBoolPref("extensions.swaksmack.alerts.global_enable_boolpref",false);
		}

	},
	highlightChoice: function(comp) {
		//ssopts.cacheOptions();
		//alert(comp.value);
		ssopts.cacheHighlightOptions(ssopts.hlchoice);
		if (comp.value == "1") {
			ssopts.initializeHighlight1();
			ssopts.hlchoice = "1";
		}		
		else if (comp.value == "2") {		
			//alert('old value ' + ssopts.hlchoice);
			ssopts.initializeHighlight2();
			ssopts.hlchoice = "2";
		}
		else if (comp.value == "3") {		
			//alert('old value ' + ssopts.hlchoice);
			ssopts.initializeHighlight3();
			ssopts.hlchoice = "3";
		}		
	},
	themeChoice: function(comp) {
		//alert(comp.value + ' ' + ssopts.themeArray.length);
		if (ssopts.themeArray == null) return;
		var theme = null;
		for (var i=0;i<ssopts.themeArray.length;i++) {
			var n = ssopts.themeArray[i].name;
			//alert('array name ' + n);
			if (n == comp.value) {
				theme = ssopts.themeArray[i];
				break;
			}
		}
		if (theme == null) return;
		//alert('theme chatBkgrd ' + theme.chatBkgrd);
		ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATTC] = theme.chatText;
		ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATBTC] = theme.chatBkgrd;
		//alert(ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATBTC] + " option data string bkcolor themechoice: " + ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.bkcolor1_stringpref"]);
		ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATNICK] = theme.chatNick;
		ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATTIME] = theme.chatTime;
		ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATGURU] = theme.chatGuru;
		ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATACTIONS] = theme.chatActions;
		ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATLINKS] = theme.chatLinks;
		ssopts.swaksmack_optionsDataString[SMACK_THEME_BKGRD] = theme.cBkgrd;
		
		var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;
		var menulist = pageDocument.getElementById('theme-elementmenu');
		menulist.value = "1";
		
		ssopts.displayStringColorPref("extensions.swaksmack.theme.bkcolor1_stringpref","theme-colorpic1");
		ssopts.displayStringValuePref("extensions.swaksmack.theme.bkcolor1_stringpref","textstringpref_chatthemecolor1");
		ssopts.themechoice = "1";
		ssopts.updateThemeSample();
		//ssopts.initThemeColors();
	},
	initThemeColors: function() {
		//NOTE: once a better theme manager is figured out, throw this away...please
		for (var i=8;i>0;i--) {
			var v = i.toString();
			ssopts.initThemeChoice(v);
			//ssopts.cacheThemeOptions(ssopts.themechoice);
		}
		ssopts.initThemeChoice("1"); //tickle and save the last cached option
		ssopts.themechoice = "1";
		//ssopts.cacheThemeOptions(ssopts.themechoice);
	},
	createCustomThemeItem: function() {
		//alert('createCustomThemeItem entry');
		var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;
		var menulist = pageDocument.getElementById('theme-choices');
		menulist.selectedIndex = 0;
		//alert('createCustomThemeItem ' + menulist.value);
		if (menulist.value != "Custom") {
			menulist.insertItemAt(0,"Custom","Custom");
		}
		
	},
	themeItemChoice: function(comp) {
		//alert('themeItemChoice entry');
		ssopts.initThemeChoice(comp.value);
	},
	initThemeChoice: function(value) {
		//ssopts.cacheOptions();
		//alert(comp.value);
		//alert(value + " initThemeChoice option data string bkcolor: " + ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.bkcolor1_stringpref"]);
		ssopts.cacheThemeOptions(ssopts.themechoice);
		//alert(value + " POST cacheTO initThemeChoice option data string bkcolor: " + ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.bkcolor1_stringpref"]);
		if (value == "1") {
			//alert("option data string bkcolor: " + ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.bkcolor1_stringpref"]);
			ssopts.displayStringColorPref("extensions.swaksmack.theme.bkcolor1_stringpref","theme-colorpic1");
			ssopts.displayStringValuePref("extensions.swaksmack.theme.bkcolor1_stringpref","textstringpref_chatthemecolor1");
			ssopts.themechoice = "1";
		}		
		else if (value == "2") {		
			ssopts.displayStringColorPref("extensions.swaksmack.theme.textcolor1_stringpref","theme-colorpic1");
			ssopts.displayStringValuePref("extensions.swaksmack.theme.textcolor1_stringpref","textstringpref_chatthemecolor1");
			ssopts.themechoice = "2";
		}
		else if (value == "3") {		
			ssopts.displayStringColorPref("extensions.swaksmack.theme.chatNick_stringpref","theme-colorpic1");
			ssopts.displayStringValuePref("extensions.swaksmack.theme.chatNick_stringpref","textstringpref_chatthemecolor1");
			ssopts.themechoice = "3";
		}
		else if (value == "4") {		
			ssopts.displayStringColorPref("extensions.swaksmack.theme.chatGuru_stringpref","theme-colorpic1");
			ssopts.displayStringValuePref("extensions.swaksmack.theme.chatGuru_stringpref","textstringpref_chatthemecolor1");
			ssopts.themechoice = "4";
		}
		else if (value == "5") {		
			ssopts.displayStringColorPref("extensions.swaksmack.theme.chatTime_stringpref","theme-colorpic1");
			ssopts.displayStringValuePref("extensions.swaksmack.theme.chatTime_stringpref","textstringpref_chatthemecolor1");
			ssopts.themechoice = "5";
		}
		else if (value == "6") {	
			//alert(ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.chatActions_stringpref"] + ' theme action ' + ssopts.getStringPref("extensions.swaksmack.theme.chatActions_stringpref", true));	
			ssopts.displayStringColorPref("extensions.swaksmack.theme.chatActions_stringpref","theme-colorpic1");
			ssopts.displayStringValuePref("extensions.swaksmack.theme.chatActions_stringpref","textstringpref_chatthemecolor1");
			ssopts.themechoice = "6";
		}
		else if (value == "7") {	
			//alert(ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.chatActions_stringpref"] + ' theme action ' + ssopts.getStringPref("extensions.swaksmack.theme.chatActions_stringpref", true));	
			ssopts.displayStringColorPref("extensions.swaksmack.theme.chatLinks_stringpref","theme-colorpic1");
			ssopts.displayStringValuePref("extensions.swaksmack.theme.chatLinks_stringpref","textstringpref_chatthemecolor1");
			ssopts.themechoice = "7";
		}	
		else if (value == "8") {	
			//alert(ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.cBkgrd_stringpref"] + ' initThemeChoice8 ' + ssopts.getStringPref("extensions.swaksmack.theme.cBkgrd_stringpref", true));	
			ssopts.displayStringColorPref("extensions.swaksmack.theme.cBkgrd_stringpref","theme-colorpic1");
			ssopts.displayStringValuePref("extensions.swaksmack.theme.cBkgrd_stringpref","textstringpref_chatthemecolor1");
			ssopts.themechoice = "8";
		}
		ssopts.updateThemeSample();			
	},
	saveTheme: function() {
		var sct = ssopts.getStringPref("extensions.swaksmack.theme.userThemes_stringpref",true);

		var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;
		var menu = pageDocument.getElementById('theme-elementmenu');
		ssopts.cacheThemeOptions(ssopts.themechoice);
		ssopts.initThemeColors();
		menu.value = "1";
		var oRegExp = new RegExp("^[,#\|]","i");
		var answer = prompt('Enter theme name','');
		if (answer == null || answer == '') return;
		if (oRegExp.test(answer) == true) {
		  alert('Specified theme name is invalid.');
			return;
		}
		if (answer == 'default') {
			alert("Really, 2 default themes?  How can I allow that?");
			return;
		}
		if (answer.toLowerCase() == 'custom') {
			alert("Custom is a lame theme name and is not allowed.");
			return;
		}
		if (answer.length >32) {
			alert('Max theme name length is 32 characters.  Try a shorter name.');
			return;
		}
		if (sct.match(answer) != null) {
			//alert('Specified theme name already exists.');
			var a2 = confirm('Replace theme ' + answer +'?');
			if (a2 == null) return;
			var theme = ssopts.getTheme(answer);
			if (theme == null) {
				alert('Error replacing theme ' +answer);
				return;
			}
			//alert('replacing theme tc ' + theme.chatText);
			ssopts.deleteThemeInternal(theme);
			//re-read updated theme
			sct = ssopts.getStringPref("extensions.swaksmack.theme.userThemes_stringpref",true);
		}
		try{
		//var str = buildSwakThemeString(answer,'1','2','3','4','5','6','7');
			var str = buildSwakThemeString(answer,ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATBTC],ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATTC],ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATNICK],ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATGURU],ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATTIME],ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATACTIONS],ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATLINKS],ssopts.swaksmack_optionsDataString[SMACK_THEME_BKGRD])
			//alert('chat theme str: ' + str);
			if (sct.charAt(sct.length-1) != '|') {
				sct+='|';
			}
			sct+=str;
			//alert(sct);
			ssopts.setCharPref("extensions.swaksmack.theme.userThemes_stringpref", sct);
			ssopts.setCharPref("extensions.swaksmack.theme.currentTheme_stringpref", answer);
			ssopts.initThemeChoices();
			ssopts.initThemeColors();
		}
		catch(x) {alert(x);}

	},
	getTheme: function(name) {
		var theme = null;
		for (var i=0;i<ssopts.themeArray.length;i++) {
			var n = ssopts.themeArray[i].name;
			//alert('array name ' + n);
			if (n == name) {
				theme = ssopts.themeArray[i];
				break;
			}
		}	
		return theme;	
	},
	deleteTheme: function() {
		//alert('delete theme');
		ssopts.themechoice = "1";
		var iFrame  = document.getElementById("swaksmack-options-optframe");
		var pageDocument = iFrame.contentDocument;
		var menulist = pageDocument.getElementById('theme-choices');
		//alert(menulist.value + ' delete theme menulist ' + menulist);
		var dtheme = null;
		dtheme = menulist.value;
		//alert('delete theme dtheme ' + dtheme);
		var answer = confirm('Delete theme ' + dtheme +'?');
		if (answer) {
			if (dtheme == 'default') {
				alert('I feel more secure with a default theme.');
				return;
			}
			var theme = ssopts.getTheme(dtheme);
			/*
			for (var i=0;i<ssopts.themeArray.length;i++) {
				var n = ssopts.themeArray[i].name;
				//alert('array name ' + n);
				if (n == dtheme) {
					theme = ssopts.themeArray[i];
					break;
				}
			}
			*/
		if (theme == null) return;
		ssopts.deleteThemeInternal(theme);
		//alert(theme.name + ', tn    ctheme ' + ctheme);
		var ctheme = ssopts.getStringPref("extensions.swaksmack.theme.currentTheme_stringpref");
		if (theme.name == ctheme) {
			//clear the stored theme
			ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.currentTheme_stringpref"] = 'Custom';
			ssopts.setCharPref("extensions.swaksmack.theme.currentTheme_stringpref", 'Custom');
		}
		ssopts.initThemeChoices();
		ssopts.initThemeColors();
		ssopts.createCustomThemeItem();
		}
		
	},
	deleteThemeInternal: function(theme) {
		if (theme == null) return;
			var str = buildSwakThemeString(theme.name,theme.chatBkgrd,theme.chatText,theme.chatNick,theme.chatGuru,theme.chatTime,theme.chatActions,theme.chatLinks,theme.cBkgrd);
			str = SS_escapeRegExLiterals(str);
			var dre = new RegExp(str,"ig");
			//alert('delete: ' + dre);
			var sct = ssopts.getStringPref("extensions.swaksmack.theme.userThemes_stringpref",true);
			//sct = sct.replace(/test2,#062038,#ff00ff,#FF7800,#FFBC80,#7AFFCF,#F54A91,#FFff00,#123449\|/ig,'test1,#062038,#ff00ff,#FF7800,#FFBC80,#7AFFCF,#F54A91,#FFff00,#123449|');
			//sct = sct.replace(/test1,#062038,#ff00ff,#FF7800,#FFBC80,#7AFFCF,#F54A91,#FFff00,#123449\|/ig,'');
			sct = sct.replace(dre, '');
			//alert('string post delete ' + sct);
			ssopts.setCharPref("extensions.swaksmack.theme.userThemes_stringpref", sct);

	},
	resetTheme: function(parent) {
		//var af = document.getElementById('audioFile').value;
		//alert('resetAudio af ' + af);
		var answer = confirm('Reset theme to default values?');
		if (answer) {
			var iFrame  = document.getElementById("swaksmack-options-optframe");
			var pageDocument = iFrame.contentDocument;
			var menu = pageDocument.getElementById('theme-elementmenu');
			ssopts.themechoice = "1";
			menu.value = "1";
			//var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch).getBranch("");
			var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
	 		if (prefs == null) return;
			var optionitems = new Array();
	 		optionitems = optionitems.concat(SMACK_THEME_OPTIONITEMS);
	 		for (var i=optionitems.length-1;i>=0;i--){
			 	try {
			 		prefs.clearUserPref(optionitems[i]);
			 	} catch (Exception){}
			}
			
			ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATTC] = null;
			ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATBTC] = null;
			ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATNICK] = null;
			ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATTIME] = null;
			ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATGURU] = null;
			ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATACTIONS] = null;
			ssopts.swaksmack_optionsDataString[SMACK_THEME_CHATLINKS] = null;
			ssopts.swaksmack_optionsDataString[SMACK_THEME_BKGRD] = null;
	//		ssopts.swaksmack_optionsDataBoolean[SMACK_THEME_ENABLE] = null;
			
			ssopts.initializeChatTheme();
		}
	},			
	resetIgnorePrefs: function() {
	 var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
	 //var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch).getBranch("");
	 if (prefs == null) return;
	 var answer = confirm("Reset Ignore/Block SwakSmack preferences?");
	 if (answer) {
	 	try {
	 		var optionitems = new Array();
	 		optionitems = optionitems.concat(SMACK_IGNORE_OPTIONITEMS);
	 		for (var i=optionitems.length-1;i>=0;i--){
		 	try {
		 		prefs.clearUserPref(optionitems[i]);
		 	} catch (Exception){}
		}
		
      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.blockwildcard_boolpref1"] = null;         
      ssopts.swaksmack_optionsDataString["extensions.swaksmack.ignore.ignorelist1_stringpref"]     = null;
      ssopts.swaksmack_optionsDataString["extensions.swaksmack.ignore.ignorelist2_stringpref"]     = null;
      ssopts.swaksmack_optionsDataString["extensions.swaksmack.ignore.ignorelistattend1_stringpref"]     = null;    
			ssopts.initializeIgnore();
	 }
	 catch (Exception ) {alert('error: ' + Exception);}
	 }
	},
	resetAllPrefs: function() {
		var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");

	//org	var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch).getBranch("");
	//	alert('resetAll prefs ' + prefs);
		//var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("");
	  if (prefs == null) return;
		var answer = confirm("Reset All SwakSmack preferences?");
		if (answer) {
		 try {
		 	var optionitems = new Array();
		 	optionitems = optionitems.concat(SMACK_OPTIONITEMS);
		 	optionitems = optionitems.concat(SMACK_HIGHLIGHT_OPTIONITEMS);
		 	optionitems = optionitems.concat(SMACK_THEME_OPTIONITEMS);
		 	optionitems = optionitems.concat(SMACK_IGNORE_OPTIONITEMS);
		 	optionitems = optionitems.concat(SMACK_ADV_OPTIONITEMS);
		 	optionitems = optionitems.concat(SMACK_AUDIO_OPTIONITEMS);
		 	optionitems = optionitems.concat(SMACK_APPEARANCE_OPTIONITEMS);
		 	
		 	for (var i=optionitems.length-1;i>=0;i--){
		 		try {
		 			prefs.clearUserPref(optionitems[i]);
		 		} catch (Exception){}
			}
			ssopts.swaksmack_optionsDataBoolean = [];
			ssopts.swaksmack_optionsDataInteger = [];
			ssopts.swaksmack_optionsDataString = [];
			
			ssopts.initializeAdvanced();
			//ssopts.cacheOptions();

		 
		// var r = prefs.deleteBranch("extensions.swaksmack."); //works, but you need to manually reset the prefs to default values
		// var r = prefs.clearUserPref(SMACK_ENABLEHL);  //works on individual prefs
		 //var r = prefs.resetBranch("extensions.swaksmack"); //not implemented

		 }
		 catch (Exception ) {alert('error: ' + Exception);}
		}
	},
	cacheHighlightOptions: function(hlchoice) {
		var childNodes   = null;
    var description  = null;
    var i            = 0;
    var iFrame       = document.getElementById("swaksmack-options-optframe");
    var iFrameSrc    = iFrame.getAttribute("src");
    var key          = null;
    var listCell     = null;
    var listItem     = null;
    var pageDocument = iFrame.contentDocument;
    var path         = null;
    //alert("cacheHighlightOptions " + hlchoice);
    if (iFrameSrc.indexOf("chathighlight") != -1) {
    	
    	//var hlc = pageDocument.getElementById('highlightChoice');
    	if (hlchoice == "1") {
				ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.enablehl1_boolpref1"] = pageDocument.getElementById("checkboolpref_hloptionenable1").checked;
				ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.keywordshl1_stringpref"]     = pageDocument.getElementById("textstringpref_keywordshl1").value;
	    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.usernamehl1_stringpref"]     = pageDocument.getElementById("textstringpref_usernamehl1").value;
	    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.hltextcolor1_stringpref"]     = pageDocument.getElementById("textstringpref_hltextcolor1").value;
	    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.hlbkcolor1_stringpref"]     = pageDocument.getElementById("textstringpref_hlbkcolor1").value;
	    	//ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.enablehl_boolpref1"] = pageDocument.getElementById("checkboolpref_enablehl").checked;
	      //ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.ignorecasehl_boolpref1"] = pageDocument.getElementById("checkboolpref_ignorecasehl").checked;
	    
	      
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.hlunderline1_boolpref1"] = pageDocument.getElementById("checkboolpref_hlunderline1").checked;
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.usernameonlyhl1_boolpref1"] = pageDocument.getElementById("checkboolpref_usernameonlyhl").checked;
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.wordonlyhl1_boolpref1"] = pageDocument.getElementById("checkboolpref_wordonlyhl").checked;
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.postoutlinehl1_boolpref1"] = pageDocument.getElementById("checkboolpref_postoutlinehl").checked;
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.chatwildcard1_boolpref1"] = pageDocument.getElementById("checkboolpref_chatwildcard").checked;
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.chatinfohl1_boolpref1"] = pageDocument.getElementById("checkboolpref_chatinfohl").checked;                    
    	}
			else if (hlchoice == "2") {
				ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.enablehl2_boolpref1"] = pageDocument.getElementById("checkboolpref_hloptionenable1").checked;
				ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.keywordshl2_stringpref"]     = pageDocument.getElementById("textstringpref_keywordshl1").value;
	    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.usernamehl2_stringpref"]     = pageDocument.getElementById("textstringpref_usernamehl1").value;
	    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.hltextcolor2_stringpref"]     = pageDocument.getElementById("textstringpref_hltextcolor1").value;
	    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.hlbkcolor2_stringpref"]     = pageDocument.getElementById("textstringpref_hlbkcolor1").value;  
	    	//ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.enablehl_boolpref1"] = pageDocument.getElementById("checkboolpref_enablehl").checked;
	      //ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.ignorecasehl_boolpref1"] = pageDocument.getElementById("checkboolpref_ignorecasehl").checked;
	    
	      
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.hlunderline2_boolpref1"] = pageDocument.getElementById("checkboolpref_hlunderline1").checked;
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.usernameonlyhl2_boolpref1"] = pageDocument.getElementById("checkboolpref_usernameonlyhl").checked;
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.wordonlyhl2_boolpref1"] = pageDocument.getElementById("checkboolpref_wordonlyhl").checked;
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.postoutlinehl2_boolpref1"] = pageDocument.getElementById("checkboolpref_postoutlinehl").checked;
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.chatwildcard2_boolpref1"] = pageDocument.getElementById("checkboolpref_chatwildcard").checked;          
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.chatinfohl2_boolpref1"] = pageDocument.getElementById("checkboolpref_chatinfohl").checked;  
    	}  
			else if (hlchoice == "3") {
				ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.enablehl3_boolpref1"] = pageDocument.getElementById("checkboolpref_hloptionenable1").checked;
				ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.keywordshl3_stringpref"]     = pageDocument.getElementById("textstringpref_keywordshl1").value;
	    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.usernamehl3_stringpref"]     = pageDocument.getElementById("textstringpref_usernamehl1").value;
	    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.hltextcolor3_stringpref"]     = pageDocument.getElementById("textstringpref_hltextcolor1").value;
	    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.hlbkcolor3_stringpref"]     = pageDocument.getElementById("textstringpref_hlbkcolor1").value;
	    	//ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.enablehl_boolpref1"] = pageDocument.getElementById("checkboolpref_enablehl").checked;
	      //ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.ignorecasehl_boolpref1"] = pageDocument.getElementById("checkboolpref_ignorecasehl").checked;
	    
	      
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.hlunderline3_boolpref1"] = pageDocument.getElementById("checkboolpref_hlunderline1").checked;
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.usernameonlyhl3_boolpref1"] = pageDocument.getElementById("checkboolpref_usernameonlyhl").checked;
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.wordonlyhl3_boolpref1"] = pageDocument.getElementById("checkboolpref_wordonlyhl").checked;
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.postoutlinehl3_boolpref1"] = pageDocument.getElementById("checkboolpref_postoutlinehl").checked;
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.chatwildcard3_boolpref1"] = pageDocument.getElementById("checkboolpref_chatwildcard").checked;          
	      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.chatinfohl3_boolpref1"] = pageDocument.getElementById("checkboolpref_chatinfohl").checked;  
    	}    	  	
		}
	},
	cacheThemeOptions: function(themechoice) {
		var childNodes   = null;
    var description  = null;
    var i            = 0;
    var iFrame       = document.getElementById("swaksmack-options-optframe");
    var iFrameSrc    = iFrame.getAttribute("src");
    var key          = null;
    var listCell     = null;
    var listItem     = null;
    var pageDocument = iFrame.contentDocument;
    var path         = null;
    //alert('cacheThemeOptions choice ' + themechoice);
    if (iFrameSrc.indexOf("chattheme") != -1) {
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.theme.enabletheme_boolpref1"] = pageDocument.getElementById("checkboolpref_themeenable").checked;
    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.currentTheme_stringpref"]     = pageDocument.getElementById("theme-choices").value;
    	if (themechoice == "1") {
    		ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.bkcolor1_stringpref"]     = pageDocument.getElementById("textstringpref_chatthemecolor1").value;
    	}
			else if (themechoice == "2") {
    		ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.textcolor1_stringpref"]     = pageDocument.getElementById("textstringpref_chatthemecolor1").value;
    	}
    	else if (themechoice == "3") {
    		ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.chatNick_stringpref"]     = pageDocument.getElementById("textstringpref_chatthemecolor1").value;
    	}
    	else if (themechoice == "4") {
    		ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.chatGuru_stringpref"]     = pageDocument.getElementById("textstringpref_chatthemecolor1").value;
    	}
    	else if (themechoice == "5") {
    		ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.chatTime_stringpref"]     = pageDocument.getElementById("textstringpref_chatthemecolor1").value;
    	}
    	else if (themechoice == "6") {
    		ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.chatActions_stringpref"]     = pageDocument.getElementById("textstringpref_chatthemecolor1").value;
    	} 
    	else if (themechoice == "7") {
    		ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.chatLinks_stringpref"]     = pageDocument.getElementById("textstringpref_chatthemecolor1").value;  		
    	} 
    	else if (themechoice == "8") {
    		//alert('cache theme 8 ' + pageDocument.getElementById("textstringpref_chatthemecolor1").value);
    		ssopts.swaksmack_optionsDataString["extensions.swaksmack.theme.cBkgrd_stringpref"]     = pageDocument.getElementById("textstringpref_chatthemecolor1").value;  		
    	}    	  	    	    	
    }		
	},
	cacheOptions: function() {
		

		
	//	alert('store options entry');
    var childNodes   = null;
    var description  = null;
    var i            = 0;
    var iFrame       = document.getElementById("swaksmack-options-optframe");
    var iFrameSrc    = iFrame.getAttribute("src");
    var key          = null;
    var listCell     = null;
    var listItem     = null;
    var pageDocument = iFrame.contentDocument;
    var path         = null;
    //var stringBundle = document.getElementById("swaksmack-string-bundle");

		//alert('cacheOptions ' +iFrameSrc);
    // If this is the colors page
    //if(iFrameSrc.indexOf("url") != -1)
    if(iFrameSrc == "chrome://swaksmack/content/options/url.xul")
    {
    	
    	  ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.easyurl_boolpref1"] = pageDocument.getElementById("checkboolpref_easyurl").checked;
    	  ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.maxurl_boolpref1"] = pageDocument.getElementById("checkboolpref_maxurl").checked;
        ssopts.swaksmack_optionsDataInteger["extensions.swaksmack.maxurllength_intpref"]     = pageDocument.getElementById("textintpref_maxurllength").value;
        ssopts.swaksmack_optionsDataString["extensions.swaksmack.truncurl_stringpref"]     = pageDocument.getElementById("textstringpref_truncurl").value;
        ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.tinyurl_enable_boolpref1"] = pageDocument.getElementById("checkboolpref_tinyurl_enable").checked;
      	ssopts.swaksmack_optionsDataInteger["extensions.swaksmack.tinyurl_maxurllength_intpref"]     = pageDocument.getElementById("textintpref_tinyurl_maxurllength").value;
      	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.tinyurl_enablepreview_boolpref"] = pageDocument.getElementById("checkboolpref_tinyurl_enablepreview").checked;

      	
        //ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.tinyurl_enable_boolpref1"] = pageDocument.getElementById("checkboolpref_tinyurl_enable").checked;
        //ssopts.swaksmack_optionsDataInteger["extensions.swaksmack.tinyurl_maxurllength_intpref"]     = pageDocument.getElementById("textintpref_tinyurl_maxurllength").value;
        //alert('url opts stored ' + ssopts.swaksmack_optionsDataString["extensions.swaksmack.truncurl_stringpref"]);
    }
    else if (iFrameSrc.indexOf("audio") != -1) {
    	//alert('chathighlight opts stored');
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.audio.global_enable_boolpref"] = pageDocument.getElementById("audio_global_enable").checked;
    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.audio.outwitsound_stringpref"]     = pageDocument.getElementById("audioFile").value;
    }
    else if (iFrameSrc.indexOf("alerts") != -1) {
    	//alert('chathighlight opts stored');
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.alerts.global_enable_boolpref"] = pageDocument.getElementById("checkboolpref_enableglobalalerts").checked; 
    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.outwitwarn_pref1"]     = pageDocument.getElementById("outwitWarnMenu").value;
    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.outwitvotewarn_pref1"]     = pageDocument.getElementById("voteWarnMenu").value;
    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.guruguesswarn_pref1"]     = pageDocument.getElementById("guruWarnMenu").value;
    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.smackpotwarn_pref1"]     = pageDocument.getElementById("smackpotWarnMenu").value;
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.outwitrandom_pref1"] = pageDocument.getElementById("checkboolpref_outwitrandom").checked;
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.altalertmonitor_boolpref1"] = pageDocument.getElementById("checkboolpref_altalertmonitor").checked;
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.enablealertmonitor_boolpref1"] = pageDocument.getElementById("checkboolpref_enablealertmonitordelay").checked; 
    	
    	//ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.pmchatcheck_boolpref1"] = pageDocument.getElementById("checkboolpref_pmlrmonitorenable").checked;
    } 
    else if (iFrameSrc.indexOf("chathighlight") != -1) {
    	
    

    	//alert('chathighlight opts stored');
//    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.keywordshl1_stringpref"]     = pageDocument.getElementById("textstringpref_keywordshl1").value;
//    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.usernamehl1_stringpref"]     = pageDocument.getElementById("textstringpref_usernamehl1").value;
//    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.hltextcolor1_stringpref"]     = pageDocument.getElementById("textstringpref_hltextcolor1").value;
//    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.hlbkcolor1_stringpref"]     = pageDocument.getElementById("textstringpref_hlbkcolor1").value;
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.enablehl_boolpref1"] = pageDocument.getElementById("checkboolpref_enablehl").checked;
      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.ignorecasehl_boolpref1"] = pageDocument.getElementById("checkboolpref_ignorecasehl").checked;
      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.enableJFEmployee_boolpref1"] = pageDocument.getElementById("checkboolpref_enablejfemployeehl").checked;
      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.ignoreselfposts_boolpref1"] = pageDocument.getElementById("checkboolpref_ignoreselfposts").checked;
      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.enableinlrhl_boolpref1"] = pageDocument.getElementById("checkboolpref_enableinlrhl").checked;    
//      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.hlunderline1_boolpref1"] = pageDocument.getElementById("checkboolpref_hlunderline1").checked;
//      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.usernameonlyhl1_boolpref1"] = pageDocument.getElementById("checkboolpref_usernameonlyhl").checked;
//      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.wordonlyhl1_boolpref1"] = pageDocument.getElementById("checkboolpref_wordonlyhl").checked;
//      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.postoutlinehl1_boolpref1"] = pageDocument.getElementById("checkboolpref_postoutlinehl").checked;
//      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.hl.chatwildcard1_boolpref1"] = pageDocument.getElementById("checkboolpref_chatwildcard").checked;          
			ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.dynamicusername_stringpref"]     = pageDocument.getElementById("dynamic-usernamic").value;
			ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.dynamickeyword_stringpref"]     = pageDocument.getElementById("dynamic-keyword").value;
			ssopts.swaksmack_optionsDataString["extensions.swaksmack.hl.jellyfishemployee_stringpref"] = pageDocument.getElementById("dynamic-jfemployee").value;
			ssopts.cacheHighlightOptions(ssopts.hlchoice);
			
    }
    else if (iFrameSrc == "chrome://swaksmack/content/options/chattheme.xul") {
    	ssopts.cacheThemeOptions(ssopts.themechoice);
    }
    else if (iFrameSrc == "chrome://swaksmack/content/options/ignore.xul") {
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.ignore.enableignoreposts_boolpref1"] = pageDocument.getElementById("checkboolpref_enableignoreposts").checked;
      ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.blockwildcard_boolpref1"] = pageDocument.getElementById("checkboolpref_blockwildcard").checked;          
      ssopts.swaksmack_optionsDataString["extensions.swaksmack.ignore.ignorelist1_stringpref"]     = pageDocument.getElementById("textstringpref_ignorelist1").value;
      ssopts.swaksmack_optionsDataString["extensions.swaksmack.ignore.ignorelist2_stringpref"]     = pageDocument.getElementById("textstringpref_ignorelist2").value;
      ssopts.swaksmack_optionsDataString["extensions.swaksmack.ignore.ignorelistattend1_stringpref"]     = pageDocument.getElementById("textstringpref_ignorelistattend1").value;    
    
    	  
	  	var funignore = pageDocument.getElementById("radiopref_ignoremode").selectedIndex;
	  	if (funignore == 1) {
	  		ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.ignore.funignore_boolpref1"] = true;
	  	}
	  	else {
	  		ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.ignore.funignore_boolpref1"] = false;
	  	}	
	  	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.ignore.enableCapsSupression_boolpref1"] = pageDocument.getElementById("checkboolpref_capsupression").checked;
	  	ssopts.swaksmack_optionsDataInteger["extensions.swaksmack.ignore.enableCapsThreshold_intpref1"]     = pageDocument.getElementById("textintpref_capsuppressionthreshold").value;	  	
    }
    else if (iFrameSrc == "chrome://swaksmack/content/options/enhance.xul") {
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.enhancedChatUI_boolpref"] = pageDocument.getElementById("checkboolpref_enhanceenabled").checked;
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.enhancedChatUIIcons_boolpref"] = pageDocument.getElementById("checkboolpref_enhanceicons").checked;
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.enhancedHideAvatars_boolpref"] = pageDocument.getElementById("checkboolpref_enhancehideavatars").checked;
    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.replyprefix_stringpref"]     = pageDocument.getElementById("textstringpref_replyprefix").value;
    	ssopts.swaksmack_optionsDataString["extensions.swaksmack.replysuffix_stringpref"]     = pageDocument.getElementById("textstringpref_replysuffix").value;
    	
    } 
    else if(iFrameSrc == "chrome://swaksmack/content/options/appearance.xul") {
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.appearance.displaystatusbarsale_boolpref1"] = pageDocument.getElementById("appearance_sb_sale_enable").checked;
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.appearance.displaystatusbarkw_boolpref1"] = pageDocument.getElementById("appearance_sb_kw_enable").checked;
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.appearance.displaystatusbarpm_boolpref1"] = pageDocument.getElementById("appearance_sb_pm_enable").checked;
    	ssopts.swaksmack_optionsDataBoolean["extensions.swaksmack.appearance.displaystatusbarlr_boolpref1"] = pageDocument.getElementById("appearance_sb_lr_enable").checked;
    }    
    else if (iFrameSrc == "chrome://swaksmack/content/options/advanced.xul") {
    	ssopts.swaksmack_optionsDataInteger["extensions.swaksmack.adv.chatspeed_intpref"]     = pageDocument.getElementById("intpref_adv_chatspeed").value;
    }        
   
},
saveOptions: function() {
    var parentWindow = null;
    var option       = null;
    var optionValue  = null;

    // Make sure current page is stored
    ssopts.cacheOptions();
  //  alert('saveOptions');
    // Loop through the boolean options
    for(option in ssopts.swaksmack_optionsDataBoolean)
    {
        ssopts.setBoolPref(option, ssopts.swaksmack_optionsDataBoolean[option]);
    }

    // Loop through the integer options
    for(option in ssopts.swaksmack_optionsDataInteger)
    {
        optionValue = ssopts.swaksmack_optionsDataInteger[option];

        // If the option value is set
        if(optionValue)
        {
            ssopts.setIntPref(option, optionValue);
        }
        else if(ssopts.isPrefSet(option))
        {
            ssopts.clearUserPref(option);
        }
    }

    // Loop through the string options
    for(option in ssopts.swaksmack_optionsDataString)
    {
        optionValue = ssopts.swaksmack_optionsDataString[option];

        // If the option value is set or the preference currently has a value
        if(optionValue || ssopts.isPrefSet(option) || optionValue == '')
        {
            ssopts.setCharPref(option, optionValue);
        }
    }
    
    //signal option update complete
		ssopts.setBoolPref("extensions.swaksmack.options.updated_boolpref", true);
		//reset flag
		ssopts.setBoolPref("extensions.swaksmack.options.updated_boolpref", false);

    //alert('save options done');
    //SS_onOptionsUpdate();

   ///??? webdeveloper_changeOptions();
   // webdeveloper_configureKeyboardShortcuts(false);
   
   
}
} //end ssopts
